﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TSharp.Core.Mvc.Pager.PagedList<TSharp.Core.Authentication.Facade.IUser>>" %>

<%@ Import Namespace="TSharp.Core.AppBox.Areas.Admin.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    用户管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ul>
        <li>
            <%=Html.ActionLink("创建用户", "Create", new { }, new { @class = "d", width = 600 })%>
            <%=Html.ActionLink<UserController>(m => m.Create(), "创建用户", new { @class = "d", width = 600 })%>
        </li>
    </ul>
    <%
        
    %>
    <div>
        <% var count = TempData["successCount"];
           if (count != null)
           {
        %>
        成功创建<%=count %>个用户
        <%} %>
        <% Html.RenderPartial(AreaConst.Path(AreaConst.Admin) + @"views/role/create.ascx");%>
    </div>
    <fieldset>
        <legend>用户查找 </legend>
        <% using (Html.BeginForm())
           { %>
        <%=Html.TextBox("uname") %>
        <input type="submit" value="查找" />
        <%} %>
    </fieldset>
    <fieldset>
        <legend>用户管理 </legend>
        <% var pagerstring = Html.Pager(Model, new PagerOptions() { PageIndexParameterName = "id" }); %>
        <div id="dvOrders">
            <%= pagerstring%><table>
                <tr>
                    <td>
                        登录名
                    </td>
                    <td>
                        在线？
                    </td>
                    <td>
                        上次登录
                    </td>
                    <td>
                        创建
                    </td>
                    <td>
                        未登录时间
                    </td>
                    <td>
                        邮件
                    </td>
                </tr>
                <%
                    foreach (var user in Model)
                    {
                %>
                <tr>
                    <td>
                        <%=Html.ActionLink<UserController>(m => m.Details(user.UserName), user.UserName, AreaConst.Admin, new { @class = "d", width = 600 })%>
                    </td>
                    <td>
                        <%=user.IsOnline %>
                    </td>
                    <td>
                        <%=user.LastActivityDate.ToString()%>
                    </td>
                    <td>
                        <%=user.CreationDate.ToString() %>
                    </td>
                    <td>
                        <%=SafeConvert.ToFormatString(DateTime.Now - user.LastActivityDate)%>
                    </td>
                    <td>
                        <% int? id = SafeConvert.ToInt32(Html.ViewContext.RequestContext.RouteData.Values["id"], 1);%>
                        <%= Html.ActionLink<UserController>(m => m.Delete(id,user.UserName), "删除")%>|
                        <%= Html.ActionLink<UserController>(m => m.Edit(id,user.UserName), "编辑")%>
                    </td>
                </tr>
                <%
                    }
           
                %>
            </table>
            <hr />
            <%= Html.Pager(Model)%></div>
    </fieldset>
</asp:Content>
